#include<bits/stdc++.h>
using namespace std;
int n,a[200010],p;
struct node{
	int f,num;
}l[200010],r[200010];
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		l[i-1].num=i;
		l[i-1].f=a[i];
		r[i+1].num=i;
		r[i+1].f=a[i];
	}
	int i=1;
	while(p!=n)
	{
		while(i<n)
		{
			printf("%d ",i);
			p++;
			l[i-1].num=l[i].num,l[i-1].f=l[i].f;
			r[i+1].num=r[i].num,r[i+1].f=r[i].f;
			l[i].num=l[i].f=r[i].num=r[i].f=-1;
			while(l[i].f==a[i])
			{
				i=l[i].num;
			}
			i=l[i].num;
		}
		printf("\n");
		for(int j=1;j<=n;j++) 
		{
			if(l[j].num==0)
			{
				i=j;
				break;
			}
		}
	}
	return 0;	
} 
